/*---------------------------------------------------------------------------*/
/*!	
		\mainpage		BillyBoy
		\version		0.0.0.1
		\author			TNick
		\date			July 2010
		
		
		\section		intro_sec	Introduction
 
			This is a simple application that may be used to hide the
		panels that you choose on a certain mouse gesture or on
		a keyboard shortcut.


		\section		motif_sec	Motivation
 
			As always with my projects, the strong component is the
		learning one. However, manny computer users that want to trick a
		suspicious boss may find a friend in this little one. 
		
		\section		usage_sec	Usage
 
			The application does not require any form of instalation. It does
		store some settings in the registry, but the required entrie(s) are
		created on first run.
			
		
		
		\note			This application is in beta testing stage.

		\todo
		- take the pressure off the system callbacks; implement a timer
		- add a black list for class and for window names
*/
/*---------------------------------------------------------------------------*/


/*---------------------------------------------------------------------------*/
/*!				\file				main.c
				\date				march 2010
				\author				TNick

				\brief				Main file for this application
    
	Main file holds entry point (the callback) and global data
	
*/
/* ------------------------------------------------------------------------- */
/* ========================================================================= */
//
//
//
//
/*  INCLUDES    ------------------------------------------------------------ */
	#include	"Config.h"
	#include	<windows.h>
	#include	<Commctrl.h>
	
	#include	"main.h"
	
/*  INCLUDES    ============================================================ */
//
//
//
//
/*  DEFINITIONS    --------------------------------------------------------- */

/*  DEFINITIONS    ========================================================= */
//
//
//
//
/*  DATA    ---------------------------------------------------------------- */
	
	HANDLE		hHeapApp;
	HINSTANCE	hInstance;
	HWND		hwMain;
	HWND		hW_Ls_L;
	HWND		hW_Ls_R;
	HWND		hWOpts;
	HHOOK		g_mouseHook;
	HHOOK		g_keyboardHook;
	LONG	    cxScreen;
	LONG	    cyScreen;
	HFONT		hF_Gen;
	HIMAGELIST	hImLst;
	UINT_PTR	gTimer = 0;
	BOOL		CurrentState = STATE_UNHIDDEN;
	unsigned	GestureStart = GST_ROW_INVALID;
	unsigned	Epcs = 0;
	SETT		AppStgs;

	const TCHAR	AppRegKey[] = TEXT("Software\\BillyBoy");
	const TCHAR	AppRegKeyHost[] = TEXT("Software");
	const TCHAR	AppRegKeyName[] = TEXT("BillyBoy");


	#ifdef DEBUG
		void*		lpDebugMsgBuf;	
		DWORD		dGle;
	#endif
	
	

/*  DATA    ================================================================ */
//
//
//
//
/*  FUNCTIONS    ----------------------------------------------------------- */
int __stdcall WinMain (	HINSTANCE hInst1, 
						HINSTANCE hPrevInst,
						LPSTR pCmdl,
						int ShowC)
{
	MSG msg;/* Here messages to the application are saved */
	msg.wParam = 0xFFFFFFFF;
	__try {
		if (App_Init() != FALSE)
		{
			BOOL bRet;
			/* Run the message loop. It will run until GetMessage() returns 0 */
			while ((bRet = GetMessage(&msg, (HWND) NULL, 0, 0)) != 0)
			{
				if (bRet == -1)
				{
					// handle the error and possibly exit
					break;
				}
				else 
				{ 
					/* Translate virtual-key messages into character messages */
					TranslateMessage(&msg); 
					/* Send message to WindowProcedure */
					DispatchMessage(&msg); 
				} 
			}
		}
	}
	__except(EXCEPTION_EXECUTE_HANDLER)
	{
		// todo better error handling here
		DEBUGMSGt("Exception terminates the application");
	}
	// terminate the application
	App_End();

    /* The program return - value is 0 - The value that PostQuitMessage() gave */
	ExitProcess(msg.wParam);
}

/*  FUNCTIONS    =========================================================== */
//
//
//
//
/* ------------------------------------------------------------------------- */
/* ========================================================================= */
